package priv.dajie.tzzq.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import priv.dajie.tzzq.dao.C5Mapper;
import priv.dajie.tzzq.model.QualityName;
import priv.dajie.tzzq.service.PlatformService;
import priv.dajie.tzzq.spider.model.ItemInfo;
import priv.dajie.tzzq.spider.model.SellingInfo;

/**
 * @ClassName C5ServiceImpl
 * @Description
 * @Author dajie
 * @Date 2019/10/23 11:58 下午
 * @Version V1.0
 **/
public class C5ServiceImpl implements PlatformService {

    @Autowired
    C5Mapper c5Mapper;

    @Override
    public boolean addItemPro(SellingInfo sellingInfo) {
        boolean state = c5Mapper.updateItemPro(sellingInfo);
        if (!state){
            state = c5Mapper.addItemPro(sellingInfo);
        }
        return state;
    }

    @Override
    public boolean addItem(SellingInfo sellingInfo) {
        return c5Mapper.addItem(sellingInfo);
    }

    @Override
    public boolean addInfo(ItemInfo itemInfo) {
        return c5Mapper.addInfo(itemInfo);
    }

    @Override
    public boolean updateInfo(ItemInfo itemInfo) {
        return c5Mapper.updateInfo(itemInfo);
    }

    @Override
    public Integer countItem(String id) {
        return c5Mapper.getItemCount(id);
    }

    @Override
    public ItemInfo getInfo(ItemInfo itemInfo){
        return c5Mapper.getInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfoBySteamName(String steamName) {
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setSteamName(steamName);
        return c5Mapper.getInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfoById(String id) {
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setId(id);
        return c5Mapper.getInfo(itemInfo);
    }

    @Override
    public ItemInfo getInfoByQualityName(QualityName qualityName) {
        ItemInfo itemInfo = new ItemInfo();
        itemInfo.setQualityName(qualityName);
        return c5Mapper.getInfo(itemInfo);
    }
}
